#include <QCoreApplication>
#include <QThreadPool>
#include <QDebug>

class Task1 : public QRunnable
{
public:
    Task1()
    { }
    virtual ~Task1() override
    {
        qDebug() << "~Task1()";
    }

    virtual void run() override
    {
        qDebug() << "do Task1 work:" << QThread::currentThreadId();
    }
};

class Task2 : public QRunnable
{
public:
    Task2()
    { }
    virtual ~Task2() override
    {
        qDebug() << "~Task2()";
    }

    virtual void run() override
    {
        qDebug() << "do Task2 work:" << QThread::currentThreadId();
    }
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    Task1* task1 = new Task1();
    Task2* task2 = new Task2();

    QThreadPool threadPool;
    threadPool.start(task1);
    threadPool.start(task2);
    threadPool.waitForDone();

    return a.exec();
}

